<?php
function fetchUrl($url,$options=array()) {
	$ch = curl_init($url);
	$defaultOption = array(
			CURLOPT_HEADER => 0,
			CURLOPT_TIMEOUT => 10,
			CURLOPT_RETURNTRANSFER=>1,
	);
	$options = $defaultOption+$options;
	foreach ($options as $k=>$v){
		curl_setopt($ch,$k,$v);
	}
	$res = curl_exec($ch); // Run it!
	if (curl_errno($ch)) {
		echo curl_error($ch),"\n";
		curl_close($ch);
		return false;
	}else {
		curl_close($ch);
		return $res;
	}
}
$json = (object)$_GET;
$agentType	=	array(
		'HTTP'	=>	CURLPROXY_HTTP,
		'SOCKS4'=>	CURLPROXY_SOCKS4,
		'SOCKS5'=>	CURLPROXY_SOCKS5,
);
$options = array(
		CURLOPT_HTTPPROXYTUNNEL	=>	true,
		CURLOPT_PROXYAUTH=>CURLAUTH_BASIC,
		CURLOPT_PROXY=>	$json->agt_ip,
		CURLOPT_PROXYPORT=>intval($json->agt_port),
		//代理模式
		CURLOPT_PROXYTYPE=>$agentType[$json->agt_type],
		CURLOPT_HTTPHEADER=>	array(
				'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
				'Connection: keep-alive',
				// 						"Cache-Control: max-age=0",
				'Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3',
		),
		CURLOPT_ENCODING=> 'gzip,deflate',
		CURLOPT_USERAGENT=>'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; qihu theworld)',
);
echo fetchUrl('http://kojiki.server.ne.jp/etc/pj235.cgi',$options);